import java.util.Scanner;
public class HW_01 {
    /**
     * 教员要求张浩使用面对对象思想编写一个计算器(Calculator)，可以实现两个整数的加，减，乘，除运算。
     */
    Scanner input = new Scanner(System.in);
    public double firstNum;
    public double secondNum;
    public int choice;
    /**
     * 输入
     */
    public void input(){
        System.out.print("请输入第一个数：");
        this.firstNum = input.nextDouble();
        System.out.print("请输入第二个数：");
        this.secondNum = input.nextDouble();
    }
    /**
     * 选择方法
     */
    public void method() {
        System.out.print("1.加，2.减，3.乘，4.除");
        System.out.print("请选择：");
        choice = input.nextInt();
        switch (choice){
            case 1:
                plus();
                break;
            case 2:
                subtract();
                break;
            case 3:
                multiply();
                break;
            case 4:
                divide();
                break;
            default:
                System.out.println("选择错误，请在1~4之间选择");
        }
    }
    public void plus(){
        System.out.println("加法：" + (this.firstNum));
    }
    public void subtract(){
        System.out.println("减法:" + (this.firstNum));
    }
    public void multiply(){
        System.out.println("乘法：" + (this.firstNum));
    }
    public void divide(){
        if (this.secondNum == 0){
            System.out.println("除数不能为零");
        }else {
            System.out.println("除法：" + (this.secondNum));
        }
    }

    public static void main(String[] args) {
        HW_01 operation = new HW_01();
        operation.input();
        operation.method();
    }
}
